package zy.zy2;

import java.io.File;
import java.util.LinkedList;
import java.util.Scanner;

public class Test {
    public static void reverse(File f) {
        LinkedList<File> files = new LinkedList<>();
        files.add(f);
        long cd = 0;
        while (files.size() > 0) {
            File temp = files.removeFirst();
            File[] fr = temp.listFiles();
            cd += temp.length();
            if (fr == null)
                continue;
            for (File t : fr) {
                files.add(t);
            }
        }
        System.out.println("目录占用：" + cd);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入文件路径：");
        String path = in.nextLine();
        reverse(new File(path));
    }
}
